package com.china08.yxyapi.api.manage.tec.teaching.homework.worklist.workinfo.report;

import java.text.ParseException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.entity.mg.homework.HomeworkTask;
import com.china08.yxyapi.model.YxyApiPageReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.mg.homework.HomeworkTaskRepository;

/**
 *
 * 给家长发送消息
 *
 */
@CrossOrigin
@RestController
public class HomeworkSendMsgParentController extends YxyApiBaseController {

    @Autowired
    HomeworkTaskRepository homeworkTaskRepository;

    @ResponseBody
    @RequestMapping(value = "/api_yw/manage/tec/teaching/homework/worklist/workinfo/report/msg/send", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(//
            HttpServletRequest request, //
            HttpServletResponse response, //
            @RequestBody ReqModel reqModel, //
            RespModel respModel) throws ParseException {
        // ##
        // 获取用户基本信息
        String userId = null;
        try {
            userId = getProfile(request, response).getId();
        } catch (Exception e) {
            Assert.isTrue(false, "用户信息异常，请重新登录。");
        }
        // 作业任务
        HomeworkTask homeworkTask = homeworkTaskRepository.findOne(reqModel.taskId);
        return null;
    }

    /** 请求参数 **/
    public static class ReqModel extends YxyApiPageReqModel {
        public String taskId;
        public List<StudentParent> studentParents;
    }

    protected static class StudentParent {
        public String studentId;
        public String parentId;
    }

    /** 响应 **/
    public static class RespModel extends YxyApiRespModel {
    }
}
